<?php
/**
 * 公共Action
 * @author tangbl
 *
 */
class PublicAction extends CommonAction{	
	/**
	 * 测试页面
	 */
	public function test_excel(){
		$this->assign('UPLOAD_PATH',UPLOAD_PATH);
		
		$this->display();
	}
	public function read_excel(){
		$fileurl   = $this->_param("fileurl");
		
		vendor('PHPExcel.PHPExcel');
		
		$objReader = PHPExcel_IOFactory::createReader(Excel5); 
		$objReader->setReadDataOnly(true); 
		$objPHPExcel = $objReader->load($fileurl); 
		$objWorksheet = $objPHPExcel->getActiveSheet(); 
		$highestRow = $objWorksheet->getHighestRow(); 
		$highestColumn = $objWorksheet->getHighestColumn(); 
		$highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn); 
		$excelData = array(); 
		for ($row = 1; $row <= $highestRow; $row++) { 
		 for ($col = 0; $col < $highestColumnIndex; $col++) { 
			 $excelData[$row][] =(string)$objWorksheet->getCellByColumnAndRow($col, $row)->getValue();
		 } 
		}
		
		echo json_encode($excelData); 
	}

	public function test_onefile(){
		$this->assign('UPLOAD_PATH',UPLOAD_PATH);
		
		$this->display();
	}   
}
